import {Component, OnDestroy, OnInit} from '@angular/core';
import {PortalsService} from '../portals.service';
import {PermissionType} from '../../constants/constants';

declare var $;


@Component({
  selector: 'app-datav',
  templateUrl: './portal-dv.component.html',
  styleUrls: ['./portal-dv.component.css']
})
export class PortalDvComponent implements OnInit, OnDestroy {



  constructor(
    private portalsService : PortalsService
  ) { }

  ngOnInit() {
    this.loadData();
  }
  ngOnDestroy() {
    $('.control-sidebar').removeClass('control-sidebar-open');
    $('body').removeClass('control-sidebar-open');
  }
  private loadData() {
    this.getMenus();
  }

  private getMenus(){
    this.portalsService.getPermissions(PermissionType.menus)
      .subscribe(
        data => this.generateMenusDom(data),
        error => this.show(error)
      );
  }
  private generateMenusDom(data:any){
    // console.log(data);
  }
  private show(message:string){
    // console.log(message);
  }
}
